<template>
  <div>
    <div class="weui-tab">
      <div class="weui-tabbar">
        <router-link :to="{name:'home'}" class="weui-tabbar__item home">
          <div class="weui-tabbar__icon"></div>
          <p class="weui-tabbar__label">首页</p>
        </router-link>
        <router-link :to="{name:'product'}" class="weui-tabbar__item product">
          <div class="weui-tabbar__icon"></div>
          <p class="weui-tabbar__label">拍品</p>
        </router-link>


          <a href="javascript:;" class="weui-tabbar__item publish" ref="pub" @click.prevent="goPublish">
            <div class="weui-tabbar__icon"></div>
            <p class="weui-tabbar__label">发布</p>
          </a>


        <router-link :to="{name:'forum'}" class="weui-tabbar__item forum">
          <div class="weui-tabbar__icon"></div>
          <p class="weui-tabbar__label">消息</p>
        </router-link>

        <router-link :to="{name:'me'}" class="weui-tabbar__item me">
          <div class="weui-tabbar__icon"></div>
          <p class="weui-tabbar__label">我的</p>
        </router-link>
      </div>
    </div>

    <!--弹出框-->
    <div class="dialog" v-show="isShowDialog">
      <div class="weui-mask"></div>
      <div class="weui-dialog">
        <div class="weui-dialog__bd">仅实名认证用户才可发布拍品，请先进行实名认证</div>
        <div class="weui-dialog__ft">
          <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default" @click.prevent="cancel">取消</a>
          <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" @click.prevent="goAuthentication">立即实名认证</a>
        </div>
      </div>
    </div>

  </div>
</template>

<script>
  import {getUser,setUser,getStatusMapByKey} from '../../../assets/js/tools';
  import {ipconfig} from '../../../assets/js/ipconfig';
  import {getUserMsg} from '../../../assets/js/getData';
  export default {
    name: "footervue",
    data(){
      return {
        wxWebAuthUrl:ipconfig.wxWebAuthUrl,
        isShowDialog:false,
        user:null,

      }
    },
    methods:{
      //点击发布按钮
      goPublish(){
        this.user = getUser(this,this.$route.fullPath);
        let idCardAudited =  getStatusMapByKey('eIdCardInfoStatus').audited.val;//个人已审核7
        if(this.user){
          //判断是否实名认证，无则弹出框
          if(this.user.hasOwnProperty("userIdCardStatus")&&this.user.userIdCardStatus==idCardAudited){
            this.$router.push({name:'publish'});
          }else {
            //获取用户信息
            getUserMsg().then(res => {
              if(res.data.reqResult.code>0){
                let data = res.data.data.user;
                //实名认证状态
                if(data.hasOwnProperty("userIdCardStatus")){
                  this.user.userIdCardStatus = data.userIdCardStatus;
                  setUser(this.user);
                  if(this.user.userIdCardStatus==idCardAudited){
                    this.$router.push({name:'publish'});
                  }else {
                    this.isShowDialog = !this.isShowDialog;
                  }
                }else {
                  this.isShowDialog = !this.isShowDialog;
                }
              }else {
                Toast(res.data.reqResult.msg);
              }
            })
          }
        }
      },
      cancel(){
        this.isShowDialog = !this.isShowDialog;
      },
      //点击立即实名认证按钮
      goAuthentication(){
        this.isShowDialog = !this.isShowDialog;
        let idCardAuditting =  getStatusMapByKey('eIdCardInfoStatus').auditting.val;//个人信息审核状态6
        let idCardNotPass =  getStatusMapByKey('eIdCardInfoStatus').notPass.val;//个人信息审核状态1
        if(this.user.hasOwnProperty("userIdCardStatus")){
          if(this.user.userIdCardStatus==idCardAuditting){
            this.$router.push({name:'personAudit'});
          }else if(this.user.userIdCardStatus==idCardNotPass){
            this.$router.push({name:'personFail'});
          }
        }else {
          this.$router.push({name:'personAut'});
        }
      },
    }
  }
</script>

<style scoped>
  .weui-tab{
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    height: 2.45rem;

  }
  .weui-tabbar{
    background-color: #FFFFFF;
    box-shadow: 0px 0px 1px rgba(0,0,0,0.25);
  }
  .weui-tabbar:before{
    display: none;
  }
  .weui-tabbar__item{
    padding: 0;
    padding-top: 0.3rem;
  }
  .weui-tabbar__icon{
    width: 1.25rem;
    height: 1.25rem;
    background-repeat: round;
  }
  .weui-tabbar__label{
    font-size: 0.5rem;
    line-height: 0.9rem;
    color: #656565;
  }
  .publish{
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }
  .home .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/home.png");
  }
  .product .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/product.png");
  }
  .publish .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/publish.png");
    position: absolute;
    width: 2.7rem;
    height: 2.7rem;
    top: -1.1rem;
    left: 50%;
    transform: translatex(-50%);
  }
  .forum .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/xiaoxi.png");
  }
  .me .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/me.png");
  }
  .router-link-active .weui-tabbar__label{
    color: #C50000;
  }
  .home.router-link-active .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/homeActive.png");
  }
  .product.router-link-active .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/productActive.png");
  }
  .publish.router-link-active .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/publishActive.png");
  }
  .forum.router-link-active .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/xiaoxiActive.png");
  }
  .me.router-link-active .weui-tabbar__icon{
    background-image: url("../../../../static/images/home/meActive.png");
  }

</style>
